package thread;

public class ThreadDemo31 {
    public static void main(String[] args) {
        Object A=new Object();
        Object B=new Object();

        Thread t1=new Thread(()->{
            synchronized (A){
                System.out.println("获取锁A");
            }

            synchronized (B){
                System.out.println("线程t1拿到两把锁");
            }
        });

        Thread t2=new Thread(()->{
            synchronized (B){
                System.out.println("获取锁B");
            }

            synchronized (A){
                System.out.println("线程t1拿到两把锁");
            }
        });
    }
}
